package com.iyjhsoc.game.domain.response;


import com.iyjhsoc.game.ENUM.ConstantENUM;

import lombok.Data;

@Data
public class Response<T> {
    private T data;
    private String msg;
    private Integer code;

    private Response(String msg, Integer code, T data){
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public static Response SUCCESS(Object data){
        return  new Response("成功",1,data);

    }

    public static Response SUCCESS(ConstantENUM msgEnum){
        return new Response(msgEnum.getMsg(),1,null);
    }
    public static Response SUCCESS(String msg, Object data){
        return  new Response(msg,1,data);
    }
    public static Response SUCCESS(){
        return  new Response("成功",1,null);
    }

    public static Response UN_AUTHORITY(){
        return  new Response("没有权限",0,null);
    }

    public static Response ERROR(){
        return new Response("系统异常，请联系管理员",-1,null);
    }

    public static Response ERROR(String msg){
        return new Response(msg,-1,null);
    }


    public static Response ERROR(ConstantENUM msgEnum){
        return new Response(msgEnum.getMsg(),-1,null);
    }
}
